package cn.nfwx.tv.widget.qpop;

import android.content.res.Resources;
import android.graphics.Color;
import android.graphics.Typeface;
import android.support.annotation.Nullable;
import android.view.ViewGroup;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;

import java.util.List;

import cn.nfwx.tv.R;
import cn.nfwx.tv.util.LogUtil;

/**
 * Created by dell on 2018/4/8.
 */

public class QpopDateAdapter extends BaseQuickAdapter<String, BaseViewHolder> {

    private int selection = 3;

    public QpopDateAdapter() {
        super(R.layout.item_review_date);
    }

    @Override
    protected void convert(BaseViewHolder helper, String item) {
        if (selection == helper.getLayoutPosition()) {
            ((TextView) helper.itemView).setText(item);
            ((TextView) helper.itemView).setTextColor(Color.parseColor("#ffffff"));
            ((TextView) helper.itemView).setTextSize(18);
            ((TextView) helper.itemView).setTypeface(Typeface.defaultFromStyle(Typeface.BOLD));
        } else {
            ((TextView) helper.itemView).setTextSize(15);
            ((TextView) helper.itemView).setTextColor(Color.parseColor("#999999"));
            ((TextView) helper.itemView).setText(item);
            ((TextView) helper.itemView).setTypeface(Typeface.defaultFromStyle(Typeface.NORMAL));
        }
        Resources r = helper.itemView.getResources();
        if (helper.getLayoutPosition() == 0) {
            helper.itemView.setPadding((int) r.getDimension(R.dimen.dp190) / 2, 0, 0, 0);
        } else if (helper.getLayoutPosition() == getItemCount() - 1) {
            helper.itemView.setPadding(0, 0, (int) r.getDimension(R.dimen.dp190) / 2, 0);
        } else {
            helper.itemView.setPadding(0, 0, 0, 0);
        }
    }

    public void setSelection(int select) {
        selection = select;
        notifyDataSetChanged();
    }

    public int getSelection() {
        return selection;
    }
}
